import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:graduation_project/cartoon_module/vertical_list.dart';

class vertical_list_view extends StatefulWidget {
  vertical_list_view({Key key, this.list_id}) : super(key: key);
  int list_id;
  @override
  State<vertical_list_view> createState() => _vertical_list_viewState();
}

class _vertical_list_viewState extends State<vertical_list_view> {
  List cartoon_list1 = [
    {
      'cartoon': 0,
      'imageUrl': 'http://www.itying.com/images/flutter/1.png',
      'name': '姓名',
      'author': '作者',
      'tage': '标签',
      'stae': '状态'
    },
    {
      'cartoon': 0,
      'imageUrl': 'http://www.itying.com/images/flutter/1.png',
      'name': '姓名',
      'author': '作者',
      'tage': '标签',
      'stae': '状态'
    },
    {
      'cartoon': 0,
      'imageUrl': 'http://www.itying.com/images/flutter/1.png',
      'name': '姓名',
      'author': '作者',
      'tage': '标签',
      'stae': '状态'
    },
    {
      'cartoon': 0,
      'imageUrl': 'http://www.itying.com/images/flutter/1.png',
      'name': '姓名',
      'author': '作者',
      'tage': '标签',
      'stae': '状态'
    },
    {
      'cartoon': 0,
      'imageUrl': 'http://www.itying.com/images/flutter/1.png',
      'name': '姓名',
      'author': '作者',
      'tage': '标签',
      'stae': '状态'
    },
    {
      'cartoon': 0,
      'imageUrl': 'http://www.itying.com/images/flutter/1.png',
      'name': '姓名',
      'author': '作者',
      'tage': '标签',
      'stae': '状态'
    },
  ];

  List cartoon_list0 = [
    {
      'cartoon': 0,
      'imageUrl': 'http://www.itying.com/images/flutter/1.png',
      'name': '姓名',
      'author': '作者',
      'tage': '标签',
      'stae': '状态'
    },
    {
      'cartoon': 0,
      'imageUrl': 'http://www.itying.com/images/flutter/1.png',
      'name': '姓名',
      'author': '作者',
      'tage': '标签',
      'stae': '状态'
    },
    {
      'cartoon': 0,
      'imageUrl': 'http://www.itying.com/images/flutter/1.png',
      'name': '姓名',
      'author': '作者',
      'tage': '标签',
      'stae': '状态'
    },
    {
      'cartoon': 0,
      'imageUrl': 'http://www.itying.com/images/flutter/1.png',
      'name': '姓名',
      'author': '作者',
      'tage': '标签',
      'stae': '状态'
    },
    {
      'cartoon': 0,
      'imageUrl': 'http://www.itying.com/images/flutter/1.png',
      'name': '姓名',
      'author': '作者',
      'tage': '标签',
      'stae': '状态'
    },
    {
      'cartoon': 0,
      'imageUrl': 'http://www.itying.com/images/flutter/1.png',
      'name': '姓名',
      'author': '作者',
      'tage': '标签',
      'stae': '状态'
    },
  ];

  ScrollController _scrollController = new ScrollController();
  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    _scrollController.addListener(() {
      if (_scrollController.position.pixels ==
          _scrollController.position.maxScrollExtent) {
        // _onLoadmore();
        print('滑到了最底部');
        cartoon_list1..addAll(cartoon_list0);
        setState(() {});
      }

      // print('滑了');
    });
  }

  @override
  Widget build(BuildContext context) {
    return RefreshIndicator(
      onRefresh: () async {
        //模拟网络请求
        setState(() {
          // rank_num = 0;
        });
        print('上拉刷新');
        await Future.delayed(Duration(milliseconds: 2000));
        //结束刷新
        return Future.value(true);
      },
      child: ListView(
        controller: _scrollController,
        // shrinkWrap: true,
        children: [
          vertical_list(
            cattoon_list: cartoon_list1,
          ),
          Container(
            height: 60,
          )
        ],
      ),
    );
  }
}
